package com.anxinr.controller.commodity;

import com.anxinr.pojo.base.QueryBase;
import com.anxinr.pojo.dto.CommodityDTO;
import com.anxinr.pojo.dto.ShopDTO;
import com.anxinr.pojo.entity.Commodity;
import com.anxinr.result.Result;
import com.anxinr.service.CommodityService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author anxinr
 */
@CrossOrigin
@RestController
@RequestMapping("/commodity")
@Api("商品模块")
@Slf4j
public class CommodityController{
    @Autowired
    private CommodityService commodityService;

    @ApiOperation("查看该门店的商品")
    @PostMapping("/queryCommodity")
    public Result<PageInfo<List<CommodityDTO>>> queryCommodity(@RequestBody QueryBase<CommodityDTO> commodity){
        return new Result(commodityService.queryCommodity(commodity)) ;
    }
    @ApiOperation("新增门店商品")
    @PostMapping("/addCommodity")
    public Result addCommodity(@RequestBody CommodityDTO commodity){
        commodityService.addCommodity(commodity) ;
        return Result.success() ;
    }

}